home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Tools / ProcDump 1.6.2 / BHRAMA / C / MAIN.C < prev   
Encoding:
C/C++ Source or Header  |  1999-04-18  |  1.7 KB  |  57 lines

  1. /* 
  2.  * Bhrama Client-Server Interface 0.3
  3.  * (c)1999 CindyG
  4.  *
  5.  * main.c : test application for bhrama c interface
  6.  */
  7.  
  8. #define WIN32_LEAN_AND_MEAN
  9. #define STRICT
  10. #include <windows.h>
  11. #include <commdlg.h>
  12. #include "bhrama.h"
  13.  
  14. void main(void)
  15. {
  16.     STARTUPINFO            sinfo;
  17.     PROCESS_INFORMATION    pinfo;
  18.     OPENFILENAME        ofn;
  19.     CHAR                filename[260];
  20.  
  21.     /* Get the target filename */
  22.     ZeroMemory(&ofn, sizeof(ofn));
  23.     ofn.lStructSize  = sizeof(ofn);
  24.     ofn.lpstrFilter  = "Executable Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0";
  25.     ofn.nFilterIndex = 1;
  26.     ofn.lpstrFile    = filename;
  27.     ofn.nMaxFile     = sizeof(filename);
  28.     ofn.lpstrTitle   = "Select protected file to open";
  29.     ofn.Flags        = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON;
  30.     if (0 == GetOpenFileName(&ofn)) {
  31.         return;
  32.     }
  33.  
  34.     /* Create the process */
  35.     ZeroMemory(&sinfo, sizeof(sinfo));
  36.     sinfo.cb = sizeof(sinfo);
  37.     if (0 == CreateProcess(NULL, filename, NULL, NULL, FALSE, CREATE_SUSPENDED | NORMAL_PRIORITY_CLASS, NULL, NULL, &sinfo, &pinfo)) {
  38.         MessageBox(NULL, "Failed to create process", "Error", MB_ICONERROR | MB_OK);
  39.         return;
  40.     }
  41.  
  42.     /* Wait for user verification */
  43.     MessageBox(NULL, "Select 'AutoFix PE' in the Bhrama Server.\nPress OK to dump.", "Dump", MB_OK);
  44.         
  45.     /* Dump the process */
  46.     if (TRUE == bhrama_dump(pinfo.dwProcessId, 0, 0, BHRAMA_IMPORT_USE, BHRAMA_OPT_DEFAULT)) {
  47.         /* todo: switch to ProcDump save dialog */
  48.         MessageBox(NULL, "Dump successful.", "Joy", MB_OK | MB_ICONINFORMATION);
  49.     } else {
  50.         MessageBox(NULL, "Dump failed. Check if Bhrama Server is running.", "Error", MB_OK | MB_ICONERROR);
  51.     }
  52.  
  53.     /* Terminate the process */
  54.     TerminateProcess(pinfo.hProcess, -28);
  55. }
  56.  
  57.